#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
	FILE *myfile=fopen("./mybziotest.txt","r+");

	fseek(myfile,0,SEEK_END);
	long filelen=ftell(myfile);
	printf("size=%ld\n",filelen);
	rewind(myfile);

	int num=fgetc(myfile);
	printf("ascii=%d->%c \n",num,num);
	
	char buf[32];
	fseek(myfile,0,SEEK_SET);
	fgets(buf,sizeof(buf),myfile);
	
	int len=strlen(buf);
	for(int i=0;i<len;i++)
	{
		printf("%c",buf[i]);
	}	
//	puts(buf);

	fseek(myfile,0,SEEK_END);
	fputs("Hello world ",myfile);
	
	char name[9]={"fengxueyu"};
	fwrite(name,sizeof(name),1,myfile);

	char myname[32];
	sprintf(myname,"fengxueyu");
	puts(myname);

	char myworld[32];
	snprintf(myworld,8,"lingyao");
	puts(myworld);

	fprintf(myfile,myworld);

	return 0;
}
